#include "geometry.h"
#include "util.h"

#define MAX_POINTS 5000*5000

struct Tile
{
	int n, e, s, w;
	int numSubtiles, numSubdivs, numPoints, numSubPoints;
	int** subdivs;
	Vec2 *points, *subPoints;
};

class WangTile
{
	float clipMinX, clipMaxX, clipMinY, clipMaxY;
	int numTiles, numSubtiles, numSubdivs;
	Tile * tiles;
	int densTexSize;
	float * densTex;
	Vec3 vpos;

	float sampleDensMap(float x, float y);
	void recurseTile(Tile & t, float x, float y, int level);

public:
	Vec3 * points;
	int numPoints;
	float toneScale;

	void paintPoints();
	void savePoints(const char * fileName);
	void loadTileSet(const char * fileName);
	WangTile();
	~WangTile();
};